#ifndef CUSTOMDATA_H
#define CUSTOMDATA_H

#include <QList>
#include <QVector>
#include <QVector3D>
#include <QColor>
#include "SplineProxy.h"
struct ColorMap
{
    QColor minColor;
    QColor maxColor;
    uint mapLevels;
};

struct VertexData
{
    QVector<QVector3D> position;
    QVector<QVector3D> color;
    QVector<QVector3D> normal;
    QVector<QVector2D> texCoord;
};

class CustomData
{
public:
    CustomData();
    void AddStringData(QList<QList<float>> lstX,QList<QList<float>> lstY,QList<QList<float>> lstZ);
    void AddWellData(QList<QList<float>> lstX,QList<QList<float>> lstY,QList<QList<float>> lstZ);
    void AddStringFEMData(QHash<QString,QVector<double>> data);
    void AddTouchData(QHash<QString,QVector<double>> data);
    void GetWellRange(float& xMin,float& xMax,float& yMin,float& yMax,float& zMin,float& zMax);
    void GetStringRange(float& xMin,float& xMax,float& yMin,float& yMax,float& zMin,float& zMax);
    QList<QString> GetFEMParams();
    void GetAxisInfo(float& xMin,float& xMax,float& yMin,float& yMax,float& zMin,float& zMax);
    QVector<QVector3D> GetColorMapsByZ(bool isString,ColorMap colorMap);
    VertexData GetStringVertexData(bool isDependOther,QList<float>* lstRange,ColorMap mapColor);
    VertexData GetWellVertexData(bool isDependOther,QList<float>* lstRange,ColorMap mapColor);
    QVector<QVector3D> GetColorMapByName(QString name,ColorMap colorMap);
    QVector<uint> GetStringFaceStripData();
    QVector<uint> GetWellFaceStripData();

    bool IsExistStringData();
    bool IsExistWellData();

    uint GetStringVertexCount();
    uint GetStringFaceCount();

    uint GetWellVertexCount();
    uint GetWellFaceCount();
private:

    QVector3D calculateNormalizeData(bool isString,bool isDependOther,int i,int j);
    QVector3D calculateNormal(bool isString,int i,int j);
    QVector3D calculateColorMap(bool isString,int i,int j,ColorMap colorMap);
    void CalculateVertexDataAndFaceStripData(bool isString,bool isDependOther,ColorMap mapColor);

    QList<QList<float>> lstStringX;
    QList<QList<float>> lstStringY;
    QList<QList<float>> lstStringZ;

    QList<QList<float>> lstWellX;
    QList<QList<float>> lstWellY;
    QList<QList<float>> lstWellZ;

    float xStringMax;
    float xStringMin;
    float yStringMin;
    float yStringMax;
    float zStringMax;
    float zStringMin;
    float xStringRate,yStringRate,zStringRate;

    float xWellMax;
    float xWellMin;
    float yWellMin;
    float yWellMax;
    float zWellMax;
    float zWellMin;
    float xWellRate,yWellRate,zWellRate;

    float xSetMax;
    float xSetMin;
    float ySetMin;
    float ySetMax;
    float zSetMax;
    float zSetMin;

    float xMax;
    float xMin;
    float yMin;
    float yMax;
    float zMax;
    float zMin;

    uint mStringMaxAxis;
    uint mWellMaxAxis;

    quint32 stringVertorNum;
    quint32 stringIndiceCount;

    quint32 wellVertorNum;
    quint32 wellIndiceCount;

    VertexData stringVertexData;
    VertexData wellVertexData;

    QVector<uint> stringFaceStrip;
    QVector<uint> wellFaceStrip;

    QList<QList<QVector3D>> lstStringFaceNormal;
    QList<QList<QVector3D>> lstWellFaceNormal;

    SplineProxy *splineProxy;
    QHash<QString,QVector<double>> stringFEMData;
    QHash<QString,QVector<double>> touchData;
};

#endif // CUSTOMDATA_H
